<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组别列表</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <style>
        .search_checkbox{
            margin: 0;
            padding: 0;
            margin-left: 15px;
            display: inline-block;
            height: 30px;
            padding-top: 12px;
        }
        .search_checkbox input[type=checkbox]{
            height: 0px;
            width: 0px;
            visibility: hidden;
        }
        .search_checkbox label{
            cursor: pointer;
            height: 20px;
            border-radius: 10px;
            display: inline-block;
            background-color: gray;
            width: 40px;
            text-indent: -99999px;
            position: relative;
        }
        .search_checkbox label::before {
            content: '';
            display:inline-block;
            background-color: white;
            height: 15px;
            width: 15px;
            position: absolute;
            top: 2.5px;
            left: 2.5px;
            border-radius: 7px;
            transition:0.3s;
        }
        .search_checkbox input:checked + label {background: #bada55;}
        .search_checkbox input:checked + label:before {left: calc(100% - 2.5px);transform: translateX(-100%);}
        .search_checkbox label:active:before{width:20px;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>MT4组别</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link"  href="javascript:location.replace(location.href);" title="刷新">
                            <i class="fa fa-refresh"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-1 m-b-xs">
                            <a  href="group_add.html" class="btn btn-w-m btn-success">添加</a>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th> </th>
                                <th>ID</th>
                                <th>组别名</th>
                                <th>类型</th>
                                <th>返佣比率</th>
                                <th>交易只读</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <foreach name="data" item="data">
                                <tr>
                                    <td>
                                        <!--<input type="checkbox" class="i-checks" name="input[]">-->
                                    </td>
                                    <td>{$data.id}</td>
                                    <td>{$data.mt4_group}</td>
                                    <td>{$data.type}</td>
                                    <td>{$data.ratio}</td>
                                    <td>
                                        <div class='search_checkbox'>
                                            <input onchange="enable_read_only(this,'{$data.mt4_group}')" type='checkbox' <if condition="$data.enable_read_only eq 1">checked</if> id= 'switch_{$data.id}'>
                                            <label for='switch_{$data.id}'></label></div>
                                    </td>
                                    <td>
                                        <a title="编辑"  onclick="Group_del('编辑','__MODULE__/System/group_save/id/{$data.id}',600,350);"   href="javascript:;" ><i class="fa fa-search-plus text-navy"></i></a>
                                        <a title="删除"  onclick="Group_delete(this,'{$data.id}');"><i class="fa fa-trash text-navy"></i></a>
                                    </td>
                                </tr>
                            </foreach>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<include file="Index/common_js"/>
<!-- Peity -->
<script src="__PUBLIC__/admin/js/plugins/peity/jquery.peity.min.js"></script>
<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/common/js/layer_show.js"></script>
<!-- iCheck -->
<script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
<!-- Peity -->
<script src="__PUBLIC__/admin/js/demo/peity-demo.js"></script>
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });

    function Group_delete(obj,id) {
        layer.confirm('确认删除吗？', function () {
            if (id == '') {
                layer.msg('操作错误，请刷新再试');
                return false;
            } else {
                $.post('__MODULE__/System/group_delete', {id: id}, function (data) {
                    if (data.status == 1) {
                        layer.msg(data.msg);
                        $(obj).parents("tr").remove();
                    } else {
                        layer.msg(data.error);
                    }
                })
            }

        })
    }

    function Group_del(title,url,w,h) {
        layer_show(title,url,w,h);
    }

    function enable_read_only(obj,group){
        var status=$(obj).is(':checked');
        //alert(status+'***'+group);return;
        var enable_read_only;
        if(status){
            enable_read_only=1;
        }else{
            enable_read_only=0;
        }
        var index = layer.load();
        $.ajax({
            type:"POST",
            url:"__URL__/updateEnableReadOnly",
            dataType:'json',
            data:{group:group,enable_read_only:enable_read_only},
            success:function(data){
                //console.log(data);
                //alert(JSON.stringify(data));return;
                layer.close(index);
                if(data.status==1){
                    layer.msg(data.msg,{icon: 1, time: 2000});
                }else{
                    $(obj).removeAttr("checked");//取消选中
                    layer.msg(data.msg,{icon: 2, time: 2000});
                }
            },error:function(err){
                $(obj).removeAttr("checked");//取消选中
                //console.log(err);
                layer.close(index);
                layer.msg('网络错误',{icon: 2, time: 2000});
            }
        });
    }
</script>
</body>
</html>
